<?php

include_once 'Classes/PHPCodeProvider.php';

/*
 * Create an instance of the CodeGeneratorOptions class
 * using the default options for code generation.
 */

$options = new CodeGeneratorOptions();

/*
 * Create an instance of the IndentedTextWriter.
 */

$writer = new IndentedTextWriter();

/*
 * VariableReferenceExpression example usage with BinaryOperatorExpression
 */

$variableRef = new VariableReferenceExpression('hits');
$zero = new PrimitiveExpression(0);
$binaryExpression = new BinaryOperatorExpression(
    BinaryOperator::ASSIGN, $variableRef, $zero);

/*
 * Generate the code
 */

$provider = new PHPCodeProvider();

$provider->generateCodeFromExpression($binaryExpression, $writer, $options);

echo 
    '<pre>' . str_replace(
        '<br />', '', highlight_string($writer->get_String(), true)) . 
    '<pre/>';

/*
 * The output should be :
 * 
 * $hits = 0
 * 
 */

?>
